<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>vuepress-plugin-migrate | VuePress 社区</title>
    <meta name="generator" content="VuePress 1.4.1">
    <link rel="icon" href="/logo/600x600.png">
    <meta name="description" content="社区维护的 VuePress 生态系统">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileColor" content="#000000">
    <link rel="preload" href="/assets/css/0.styles.6c0c5975.css" as="style"><link rel="preload" href="/assets/js/app.642d23b3.js" as="script"><link rel="preload" href="/assets/js/40.20d66e6f.js" as="script"><link rel="preload" href="/assets/js/page-c9903bc8.3b89aecd.js" as="script"><link rel="preload" href="/assets/js/42.2c37f203.js" as="script"><link rel="prefetch" href="/assets/js/41.3a1d8c85.js"><link rel="prefetch" href="/assets/js/43.6ef7f18f.js"><link rel="prefetch" href="/assets/js/44.b27fbcf7.js"><link rel="prefetch" href="/assets/js/45.c3252ceb.js"><link rel="prefetch" href="/assets/js/46.9c844637.js"><link rel="prefetch" href="/assets/js/page-07d1601e.242c2d2a.js"><link rel="prefetch" href="/assets/js/page-07f51dda.32726b1b.js"><link rel="prefetch" href="/assets/js/page-0a6678e5.628ba2fc.js"><link rel="prefetch" href="/assets/js/page-0f8f6766.b84a099f.js"><link rel="prefetch" href="/assets/js/page-1204fa10.e7865c5b.js"><link rel="prefetch" href="/assets/js/page-12e4fd46.7452ae30.js"><link rel="prefetch" href="/assets/js/page-14660f14.f5838285.js"><link rel="prefetch" href="/assets/js/page-17a68826.0f6f2110.js"><link rel="prefetch" href="/assets/js/page-1982deb4.01bbc28c.js"><link rel="prefetch" href="/assets/js/page-216dd7c6.119f4c59.js"><link rel="prefetch" href="/assets/js/page-2d1fe5d8.ab8c6d4c.js"><link rel="prefetch" href="/assets/js/page-33083986.2f59b20d.js"><link rel="prefetch" href="/assets/js/page-353b8594.d79d4319.js"><link rel="prefetch" href="/assets/js/page-36ce40ea.66f2730d.js"><link rel="prefetch" href="/assets/js/page-3b6ebfa4.df1831eb.js"><link rel="prefetch" href="/assets/js/page-3e5179ee.f0d7043f.js"><link rel="prefetch" href="/assets/js/page-42f1e69c.ad94d467.js"><link rel="prefetch" href="/assets/js/page-4336d0c6.a4013cdd.js"><link rel="prefetch" href="/assets/js/page-4362efe0.40a6a106.js"><link rel="prefetch" href="/assets/js/page-4d80adb0.c788d5af.js"><link rel="prefetch" href="/assets/js/page-4eab9ae2.3c07cca2.js"><link rel="prefetch" href="/assets/js/page-5170c35e.ba839aac.js"><link rel="prefetch" href="/assets/js/page-55154126.4114c7df.js"><link rel="prefetch" href="/assets/js/page-5b4049d8.28b01370.js"><link rel="prefetch" href="/assets/js/page-5c13450a.559f8c58.js"><link rel="prefetch" href="/assets/js/page-5e11724a.743dcab4.js"><link rel="prefetch" href="/assets/js/page-6aa1c294.d5c24ca3.js"><link rel="prefetch" href="/assets/js/page-6aa62140.570cd351.js"><link rel="prefetch" href="/assets/js/page-6c372be6.1768c8fc.js"><link rel="prefetch" href="/assets/js/page-6c6f6eb8.55332c8a.js"><link rel="prefetch" href="/assets/js/page-70397cc5.38298d74.js"><link rel="prefetch" href="/assets/js/page-7a8d5874.bebc26b5.js"><link rel="prefetch" href="/assets/js/page-7bec420c.42c63b19.js"><link rel="prefetch" href="/assets/js/page-8ed296e4.ee2655fc.js"><link rel="prefetch" href="/assets/js/page-c3486808.466685fd.js"><link rel="prefetch" href="/assets/js/page-e2b999b4.9e2fd49d.js"><link rel="prefetch" href="/assets/js/page-f3f5674c.c5689d98.js">
    <link rel="stylesheet" href="/assets/css/0.styles.6c0c5975.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/zh/" class="home-link router-link-active"><!----> <span class="site-name">VuePress 社区</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">选择语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/plugins/migrate/" class="nav-link">
  English
</a></li><li class="dropdown-item"><!----> <a href="/zh/plugins/migrate/" class="nav-link router-link-exact-active router-link-active">
  简体中文
</a></li></ul></div></div> <a href="https://github.com/vuepress/vuepress-community" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">选择语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/plugins/migrate/" class="nav-link">
  English
</a></li><li class="dropdown-item"><!----> <a href="/zh/plugins/migrate/" class="nav-link router-link-exact-active router-link-active">
  简体中文
</a></li></ul></div></div> <a href="https://github.com/vuepress/vuepress-community" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>插件</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/zh/plugins/clean-urls/" class="sidebar-link">vuepress-plugin-clean-urls</a></li><li><a href="/zh/plugins/container/" class="sidebar-link">vuepress-plugin-container</a></li><li><a href="/zh/plugins/copyright/" class="sidebar-link">vuepress-plugin-copyright</a></li><li><a href="/zh/plugins/dehydrate/" class="sidebar-link">vuepress-plugin-dehydrate</a></li><li><a href="/zh/plugins/git-log/" class="sidebar-link">vuepress-plugin-git-log</a></li><li><a href="/zh/plugins/mathjax/" class="sidebar-link">vuepress-plugin-mathjax</a></li><li><a href="/zh/plugins/medium-zoom/" class="sidebar-link">vuepress-plugin-medium-zoom</a></li><li><a href="/zh/plugins/migrate/" class="active sidebar-link">vuepress-plugin-migrate</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#安装" class="sidebar-link">安装</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#使用" class="sidebar-link">使用</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#配置项" class="sidebar-link">配置项</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#targetdir" class="sidebar-link">targetDir</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#downloaddir" class="sidebar-link">downloadDir</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#maxconcurrenttasks" class="sidebar-link">maxConcurrentTasks</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#forcedownload" class="sidebar-link">forceDownload</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#forceconvert" class="sidebar-link">forceConvert</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#sitemap" class="sidebar-link">sitemap</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#getfilename" class="sidebar-link">getFileName</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#parsehtml" class="sidebar-link">parseHTML</a></li></ul></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#cli" class="sidebar-link">CLI</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#通用选项" class="sidebar-link">通用选项</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#detail" class="sidebar-link">--detail</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#f-forced" class="sidebar-link">-f, --forced</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#vuepress-download" class="sidebar-link">vuepress download</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#s-sitemap-sitemap" class="sidebar-link">-s, --sitemap &lt;sitemap&gt;</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#vuepress-convert" class="sidebar-link">vuepress convert</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#t-target-targetdir" class="sidebar-link">-t, --target &lt;targetDir&gt;</a></li><li class="sidebar-sub-header"><a href="/zh/plugins/migrate/#vuepress-migrate" class="sidebar-link">vuepress migrate</a></li></ul></li></ul></li><li><a href="/zh/plugins/named-chunks/" class="sidebar-link">vuepress-plugin-named-chunks</a></li><li><a href="/zh/plugins/nprogress/" class="sidebar-link">vuepress-plugin-nprogress</a></li><li><a href="/zh/plugins/redirect/" class="sidebar-link">vuepress-plugin-redirect</a></li><li><a href="/zh/plugins/serve/" class="sidebar-link">vuepress-plugin-serve</a></li><li><a href="/zh/plugins/smooth-scroll/" class="sidebar-link">vuepress-plugin-smooth-scroll</a></li><li><a href="/zh/plugins/table-of-contents/" class="sidebar-link">vuepress-plugin-table-of-contents</a></li><li><a href="/zh/plugins/typescript/" class="sidebar-link">vuepress-plugin-typescript</a></li><li><a href="/zh/plugins/zooming/" class="sidebar-link">vuepress-plugin-zooming</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>工具</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="vuepress-plugin-migrate"><a href="#vuepress-plugin-migrate" class="header-anchor">#</a> vuepress-plugin-migrate <a rel="noopener noreferrer" target="_blank" title="vuepress/vuepress-plugin-migrate" href="https://github.com/vuepress/vuepress-plugin-migrate" class="github-link"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28"><path d="M14 0C6.27 0 0 6.43 0 14.36c0 6.34 4.01 11.72 9.57 13.62.7.13.96-.31.96-.69 0-.34-.01-1.24-.02-2.44-3.89.87-4.72-1.92-4.72-1.92-.64-1.66-1.55-2.1-1.55-2.1-1.27-.89.1-.87.1-.87 1.4.1 2.14 1.48 2.14 1.48 1.25 2.19 3.28 1.56 4.07 1.19.13-.93.49-1.56.89-1.92-3.11-.36-6.38-1.59-6.38-7.09 0-1.57.55-2.85 1.44-3.85-.14-.36-.62-1.82.14-3.8 0 0 1.18-.39 3.85 1.47a12.8 12.8 0 0 1 3.5-.48c1.19.01 2.39.16 3.5.48 2.67-1.86 3.85-1.47 3.85-1.47.76 1.98.28 3.44.14 3.8.9 1 1.44 2.28 1.44 3.85 0 5.51-3.27 6.73-6.39 7.08.5.44.95 1.32.95 2.66 0 1.92-.02 3.47-.02 3.94 0 .38.25.83.96.69C23.99 26.07 28 20.7 28 14.36 28 6.43 21.73 0 14 0z" fill-rule="evenodd" clip-rule="evenodd"></path></svg></a></h1> <p>从其他网站迁移到 VuePress。</p> <h2 id="安装"><a href="#安装" class="header-anchor">#</a> 安装</h2> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">npm</span> <span class="token function">install</span> -D vuepress-plugin-migrate
</code></pre></div><h2 id="使用"><a href="#使用" class="header-anchor">#</a> 使用</h2> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// .vuepress/config.js</span>
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">{</span>
  plugins<span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">[</span>
      <span class="token string">'vuepress-plugin-migrate'</span><span class="token punctuation">,</span>
      <span class="token punctuation">{</span>
        targetDir<span class="token operator">:</span> <span class="token string">'_posts'</span><span class="token punctuation">,</span>
        downloadDir<span class="token operator">:</span> <span class="token string">'.vuepress/downloads'</span><span class="token punctuation">,</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="配置项"><a href="#配置项" class="header-anchor">#</a> 配置项</h2> <h3 id="targetdir"><a href="#targetdir" class="header-anchor">#</a> targetDir</h3> <ul><li><strong>类型:</strong> <code>string</code></li> <li><strong>默认值:</strong> <code>'_posts'</code></li></ul> <p>要输出 markdown 文件的目录。</p> <h3 id="downloaddir"><a href="#downloaddir" class="header-anchor">#</a> downloadDir</h3> <ul><li><strong>类型:</strong> <code>string</code></li> <li><strong>默认值:</strong> <code>'.vuepress/downloads'</code></li></ul> <p>用于存储下载文件的目录。</p> <h3 id="maxconcurrenttasks"><a href="#maxconcurrenttasks" class="header-anchor">#</a> maxConcurrentTasks</h3> <ul><li><strong>类型:</strong> <code>number</code></li> <li><strong>默认值:</strong> <code>10</code></li></ul> <p>允许的最大下载并发数。</p> <h3 id="forcedownload"><a href="#forcedownload" class="header-anchor">#</a> forceDownload</h3> <ul><li><strong>类型:</strong> <code>boolean</code></li> <li><strong>默认值:</strong> <code>false</code></li></ul> <p>当检测到 <code>.html</code> 文件已存在时是否强制下载。</p> <h3 id="forceconvert"><a href="#forceconvert" class="header-anchor">#</a> forceConvert</h3> <ul><li><strong>类型:</strong> <code>boolean</code></li> <li><strong>默认值:</strong> <code>false</code></li></ul> <p>当检测到 <code>.md</code> 文件已存在时是否强制覆盖。</p> <h3 id="sitemap"><a href="#sitemap" class="header-anchor">#</a> sitemap</h3> <ul><li><strong>类型:</strong> <code>string</code></li> <li><strong>默认值:</strong> <code>undefined</code></li></ul> <p>原网站的 sitemap 链接。</p> <h3 id="getfilename"><a href="#getfilename" class="header-anchor">#</a> getFileName</h3> <ul><li><strong>类型:</strong> <code>(url: string) =&gt; string</code></li> <li><strong>默认值:</strong> <code>url =&gt; String(++index)</code></li></ul> <p>要保存为的文件名。如果返回一个 falsy 值，则不下载对应的文件。</p> <h3 id="parsehtml"><a href="#parsehtml" class="header-anchor">#</a> parseHTML</h3> <ul><li><strong>类型:</strong> <code>($: CheerioElement, render: ($: CheerioElement) =&gt; string) =&gt; ParsedResult</code></li> <li><strong>默认值:</strong> <code>undefined</code></li></ul> <p>从爬取的 HTML 生成对应 <code>ParsedResult</code> 对象的函数。一个 <code>ParsedResult</code> 是一个含有以下属性的对象：</p> <div class="language-ts extra-class"><pre class="language-ts"><code><span class="token keyword">interface</span> <span class="token class-name">ParsedResult</span> <span class="token punctuation">{</span>
  frontmatter<span class="token operator">?</span><span class="token operator">:</span> <span class="token builtin">any</span>
  filename<span class="token operator">?</span><span class="token operator">:</span> <span class="token builtin">string</span>
  content<span class="token operator">?</span><span class="token operator">:</span> <span class="token builtin">string</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="cli"><a href="#cli" class="header-anchor">#</a> CLI</h2> <h3 id="通用选项"><a href="#通用选项" class="header-anchor">#</a> 通用选项</h3> <p>这些选项将在任何一个命令中生效。</p> <h3 id="detail"><a href="#detail" class="header-anchor">#</a> --detail</h3> <p>在遇到错误时显示详细信息。</p> <h3 id="f-forced"><a href="#f-forced" class="header-anchor">#</a> -f, --forced</h3> <p>相当于将 <a href="#forceDownload">forceDownload</a> 和 <a href="#forceConvert">forceConvert</a> 都设置为 <code>true</code>。</p> <h3 id="vuepress-download"><a href="#vuepress-download" class="header-anchor">#</a> vuepress download</h3> <p>从源网站中爬取所需的页面，并存储到本地文件夹中。</p> <h3 id="s-sitemap-sitemap"><a href="#s-sitemap-sitemap" class="header-anchor">#</a> -s, --sitemap <code>&lt;sitemap&gt;</code></h3> <p>详见 <a href="#sitemap">sitemap</a>。</p> <h3 id="vuepress-convert"><a href="#vuepress-convert" class="header-anchor">#</a> vuepress convert</h3> <p>将存储在本地的 HTML 文件转化为 markdown 文件并输出。</p> <h3 id="t-target-targetdir"><a href="#t-target-targetdir" class="header-anchor">#</a> -t, --target <code>&lt;targetDir&gt;</code></h3> <p>详见 <a href="#targetDir">targetDir</a>。</p> <h3 id="vuepress-migrate"><a href="#vuepress-migrate" class="header-anchor">#</a> vuepress migrate</h3> <p>依次完成 download 和 convert 两个命令。支持两个命令的全部参数。</p></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/vuepress/vuepress-community/edit/master/packages/docs/src/zh/plugins/migrate.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2020/1/21 上午5:05:35</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/zh/plugins/medium-zoom/" class="prev">
        vuepress-plugin-medium-zoom
      </a></span> <span class="next"><a href="/zh/plugins/named-chunks/">
        vuepress-plugin-named-chunks
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.642d23b3.js" defer></script><script src="/assets/js/40.20d66e6f.js" defer></script><script src="/assets/js/page-c9903bc8.3b89aecd.js" defer></script><script src="/assets/js/42.2c37f203.js" defer></script>
  </body>
</html>
